<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "shbb_land".
 *
 * @property integer $id
 * @property string $code
 * @property string $name
 * @property string $introduction
 * @property string $scale
 * @property string $map_image
 * @property string $tel
 * @property string $email
 * @property string $comment
 * @property integer $park_id
 * @property integer $pricipal_id
 *
 * @property ShbbEquip[] $shbbEquips
 * @property ShbbPerson $pricipal
 * @property ShbbPark $park
 */
class Land extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shbb_land';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'park_id', 'pricipal_id'], 'integer'],
            [['introduction'], 'string'],
            [['code', 'name', 'scale', 'map_image', 'tel', 'email', 'comment'], 'string', 'max' => 255],
            [['code'], 'unique'],
            ['email', 'email'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => '地块ID',
            'code' => '地块编号',
            'name' => '地块名称',
            'introduction' => '地块简介',
            'scale' => '地块规模',
            'map_image' => '地图',
            'tel' => '联系电话',
            'email' => '电子邮箱',
            'comment' => '备注',
            'park_id' => '所属园区',
            'pricipal_id' => '负责人',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getShbbEquips()
    {
        return $this->hasMany(Equip::className(), ['land_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPricipal()
    {
        return $this->hasOne(Person::className(), ['id' => 'pricipal_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPark()
    {
        return $this->hasOne(Park::className(), ['id' => 'park_id']);
    }
}
